package com.yincheng.oms.bussiness.order.util;

import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.yincheng.oms.bussiness.order.Response;
import com.yincheng.oms.bussiness.order.entity.Order;

public class ValidateUtils {

	public static Response checkOrders(List<Order> list) {
		Response response = new Response(Response.SUCCESS);
		
		for (int i = 0; i < list.size(); i++) {
			Order order = list.get(i);
			String orderNo = order.getOrderNo();
			String orderSource = order.getOrderSource();
//			String customerName = order.getCustomerName();
//			String customerPhone = order.getCustomerPhone();
			String receiverName = order.getReceiverName();
			String receiverPhone = order.getReceiverPhone();
//			String receiverAddress = order.getReceiverAddress();
			
			if(StringUtils.isEmpty(orderNo)) {
				response.setCode(Response.DATA_NULL_ERROR);
				String message = "第"+(i+2)+"行，订单编号不能为空。";
				response.setMessage(message);
				return response;
			}
			if(StringUtils.isEmpty(orderSource)) {
				response.setCode(Response.DATA_NULL_ERROR);
				String message = "第"+(i+2)+"行，订单来源不能为空。";
				response.setMessage(message);
				return response;
			}
			if(StringUtils.isEmpty(receiverName)) {
				response.setCode(Response.DATA_NULL_ERROR);
				String message = "第"+(i+2)+"行，收件人姓名不能为空。";
				response.setMessage(message);
				return response;
			}
			if(StringUtils.isEmpty(receiverPhone)) {
				response.setCode(Response.DATA_NULL_ERROR);
				String message = "第"+(i+2)+"行，收件人电话不能为空。";
				response.setMessage(message);
				return response;
			}
		}
		return response;
	}
}
